home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / tchk21.arc / INCLUDE.ARC / REAL.H < prev    next >
C/C++ Source or Header  |  1989-06-20  |  2KB  |  47 lines

  1. /* TCHK 2.1 - Howard Kapustein's Turbo C library        6-6-89      */
  2. /* Copyright (C) 1988,1989 Howard Kapustein.  All rights reserved.  */
  3.  
  4. /* real.h  -  header file for emulated real functions */
  5.  
  6. #ifndef REAL_HEADER
  7. #define REAL_HEADER  1
  8.  
  9. #include <howard.h>
  10.  
  11. #define MAXRPRECISION   8               /* maximum real precision (decimal places) */
  12.  
  13. typedef enum {
  14.     RDOMAIN = 1,    /* argument domain -- log (-1)          */
  15.     RSING,          /* argument singularity -- pow (0,-2)   */
  16.     ROVERFLOW,      /* overflow range error  -- rint > LONG_MAX     */
  17.     RUNDERFLOW,     /* underflow range error  -- rint < LONG_MIN    */
  18.     RTLOSS,         /* total loss of significance -- */
  19.     RPLOSS,         /* partial loss of significance -- */
  20.     RFRACOVER,      /* fraction overflow range error -- rfrac > LONG_MAX    */
  21.     RFRACUNDER,     /* fraction underflow range error -- rfrac < LONG_MIN   */
  22.     RDIVBYZERO,     /* divide by zero -- 1/0 */
  23. }   _rmexcep;
  24.  
  25. typedef struct REAL {
  26.             long rint;              /* real - integer */
  27.             long rfrac;             /* real - fraction */
  28.             int precision;          /* precision of fraction (# of decimal places) */
  29.         };
  30.  
  31. /* Global variables (for reference only) *//*
  32. int _r_minpre, _r_maxpre;
  33. boolean _r_maximum = FALSE;                 /* should rnormalize() try to minimize or maximize the precision */*/
  34.  
  35. /* function prototypes */
  36. struct REAL rdiv(long int numer, long int denom, int precision);    /* real division without FP emulator library */
  37. struct REAL radd(struct REAL val, struct REAL sval, int precision); /* real addition without FP emulator library */
  38. struct REAL rsub(struct REAL val, struct REAL sval, int precision); /* real subtraction without FP emulator library */
  39. void rnormalize(struct REAL *r1, struct REAL *r2);  /* normalize emulated fp values (fix the decimal places) */
  40. long lpow(long base, int exponent);         /* raise a base to an exponent */
  41. long rceil(struct REAL rx);                 /* rounds up */
  42. long rfloor(struct REAL rx);                /* rounds down */
  43. int rsign(struct REAL rx);                  /* return sign */
  44. struct REAL *rnegate(struct REAL *rx);      /* change sign */
  45.  
  46. #endif              /* REAL_HEADER */
  47.